//MINI UI解析
mini.parse();

//搜索内容处理器类
function SearchContentHandler() {
	this.data = {};
	this.selected = null;
	this.grid = mini.get("sysContentGrid");
	
	this.load = function(data, selected) {
		data = mini.clone(data);
		this.data.type = data.type;
		this.selected = selected;
		this.grid.url = __root + data.request;
	};
	
	this.search = function(name) {
		this.grid.load({scType : this.data.type, scName : name});
	};
	
	this.close = function(action) {
		if (CloseOwnerWindow) {
			CloseOwnerWindow(action);
		} else {
			window.close();
		}
	};
};

//创建搜索内容处理器全局实例
var instance = new SearchContentHandler();

//定义搜索按钮点击事件处理程序
function onScSearchClick(e) {
	var name = mini.get("scName").getValue();
	instance.search(name);
}

//定义确定按钮点击事件处理程序
function onScConfirmClick(e) {
	var row = instance.grid.getSelected();
	if (row && instance.selected) {
		instance.selected(row.value);
	}
	
	instance.close("cancel");
}

//定义关闭按钮点击事件处理程序
function onScCancelClick(e) {
	instance.close("cancel");
}

//定义系统内容表格行双击事件处理程序
function onSysContentGridRowDbclick(e) {
	if (instance.selected) {
		instance.selected(e.record.value);
	}
	
	instance.close("cancel");
}
